package com.tradeplus.admin.dao;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.tradeplus.admin.model.FunctionalArea;

public class FunctionalAreaDaoImpl implements FunctionalAreaDao {
	
	private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

	@Override
	public void saveFunctionalArea(FunctionalArea functionalArea) {
		hibernateTemplate.merge(functionalArea);
	}

	@Override
	public List<FunctionalArea> loadFunctionalArea() {
		return hibernateTemplate.find("from FunctionalArea");
	}

	@Override
	public FunctionalArea loadFunctionalAreaById(Long functionalAreaId) {
		return hibernateTemplate.get(FunctionalArea.class, functionalAreaId);
	}

	@Override
	public void deleteFunctionalArea(Long functionalAreaId) {
		hibernateTemplate.delete(hibernateTemplate.get(FunctionalArea.class, functionalAreaId));
	}

}
